<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改题库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-repo-edit" th:object="${model}">
        	<input id="id" name="id" th:field="*{id}"  type="hidden">
        	<div class="form-group">	
				<label class="col-sm-3 control-label is-required">题库编码：</label>
	            <div class="col-sm-8">
	                <input id="code" name="code" th:field="*{code}"  class="form-control" type="text" required autocomplete="off">
	            </div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label is-required">题库名称：</label>
	            <div class="col-sm-8">
	                <input id="title" name="title" th:field="*{title}"  class="form-control" type="text" required autocomplete="off">
	            </div>
			</div>
			<div class="form-group">	
	            <label class="col-sm-3 control-label">题库备注：</label>
	            <div class="col-sm-8">
	                <textarea id="remark" name="remark" th:field="*{remark}" class="form-control"></textarea>
	            </div>
	        </div>
		</form>
	</div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "exam/repo";
        $("#form-repo-edit").validate({
        	onkeyup: false,
        	rules:{
        		code:{
					required: true,
					remote: {
		                url: prefix + "/checkCodeUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	id : function() {
		                        return $.common.trim($("#id").val());
		                    },
		                	code : function() {
		                        return $.common.trim($("#code").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
        		title:{
        			required : true
        		}
        	},
        	messages: {
		        "code": {
		            remote: "该题库编码已经存在"
		        }
		    },
        	focusCleanup: true
        })
        function submitHandler() {
        	if ($.validate.form()) {
        		 $.operate.save(prefix + "/edit", $('#form-repo-edit').serialize());
        	}
        }
	</script>
</body>
</html>
